import { HTTP } from '../utils/http.js'

class GoodsHttp extends HTTP {
  // 商品搜索
  goodsSearch (data) {
    return this.request({
      url: 'goods/GoodsSearch',
      method: 'POST',
      data: data
    })
  }

  // 商品分类
  getGoodsOpts (data) {
    return this.request({
      url: 'goods/GetGoodsOpts',
      method: 'POST',
      data: data
    })
  }

  // 获取巷友商品列表
  getYddGoodsList (data) {
    return this.request({
      url: 'yddgoods/YddGoodsList',
      method: 'POST',
      data: data
    })
  }

  // 获取巷友商品详情
  getYddGoodsDetails (data, param) {
    return this.request({
      url: 'yddgoods/YddGoodDetailV2',
      method: 'POST',
      data: data,
      ...param
    })
  }

  //  获取预售商品
  getPresaleGoods (data) {
    return this.request({
      url: 'yddgoods/PresaleGoods',
      method: 'POST',
      data
    })
  }

  // 添加商品到购物车
  addCartGoods (data) {
    return this.request({
      url: 's/yddgoods/YddMyCartAdd',
      method: 'POST',
      data: data
    })
  }

  // 获取购物车商品数量
  getMyCartSum () {
    return this.request({
      url: 's/yddgoods/GetMyCartSum',
      method: 'POST',
    })
  }

  // 添加商品关注
  addGoodsLike (data) {
    return this.request({
      url: 's/lottery/AddGoodsFollow',
      method: 'POST',
      data: data
    })
  }

  // 取消商品关注
  cancelGoodsLike (data) {
    return this.request({
      url: 's/lottery/DelGoodsFollow',
      method: 'POST',
      data: data
    })
  }

  // 分享商品
  shareGoods (data) {
    return this.request({
      url: 's/yddgoods/PreShare',
      method: 'POST',
      data: data
    })
  }

  // 分享商品图片合成
  compoundShareGoodsImg (data) {
    return this.request({
      url: 's/goodsearch/QrcodeUrlShera',
      method: 'POST',
      data: data
    })
  }
  // 商品推荐、相似推荐
  GetRecommend (data) {
    return this.request({
      url: 'goods/GetRecommend',
      method: 'POST',
      data: data,
      isShowLoading:false
    })
  }
}

export { GoodsHttp }
